﻿
namespace Toggl.PhoneClient.Domain
{
    using Newtonsoft.Json;

    [JsonObject]
    public class Project
    {
        [JsonProperty(PropertyName = "id", NullValueHandling = NullValueHandling.Ignore)]
        public int? Id { get; set; }

        [JsonProperty(PropertyName = "name")]
        public string Name { get; set; }

        [JsonProperty(PropertyName = "billable")]
        public bool Billable { get; set; }

        [JsonProperty(PropertyName = "fixed_fee", NullValueHandling = NullValueHandling.Ignore)]
        public decimal? FixedFee { get; set; }

        [JsonProperty(PropertyName = "hourly_rate", NullValueHandling = NullValueHandling.Ignore)]
        public decimal? HourlyRate { get; set; }

        [JsonProperty(PropertyName = "is_fixed_fee", NullValueHandling = NullValueHandling.Ignore)]
        public bool IsFixedFee { get; set; }

        [JsonProperty(PropertyName = "client_project_name", NullValueHandling = NullValueHandling.Ignore)]
        public string ClientProjectName { get; set; }

        [JsonProperty(PropertyName = "estimated_workhours", NullValueHandling = NullValueHandling.Ignore)]
        public decimal? EstimatedWorkHours { get; set; }

        [JsonProperty(PropertyName = "automatically_calculate_estimated_workhours", NullValueHandling = NullValueHandling.Ignore)]
        public bool? AutomaticCalculateWorkHours { get; set; }

        [JsonProperty(PropertyName = "workspace", NullValueHandling = NullValueHandling.Ignore)]
        public Workspace Workspace { get; set; }

        public override bool Equals(object obj)
        {
            Project otherProject = obj as Project;
            if (this.Id.HasValue && otherProject != null && otherProject.Id.HasValue)
            {
                return this.Id.Value.Equals(otherProject.Id.Value);
            }
            return false;
        }
    }
}
